<template>
  <div class="chat_item">
    <img class="avatar" :src="props.data.avatar" alt="">
    <div class="info">
      <div class="name t_nowrap">{{ data.name }}</div>
      <div class="text t_shaodow">{{ data.text }}</div>
      <div class="activeTime t_shaodow">{{ formatDate(data.activeTime) }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps } from 'vue';
import dayjs from 'dayjs';
const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
});
function formatDate(dateStr, format = 'YYYY-MM-DD HH:mm:ss') {
  return dayjs(dateStr).format(format)
}
</script>

<style lang="less" scoped>
.chat_item {
  box-sizing: border-box;
  padding: 5px;
  width: 100%;
  height: 65px;
  display: flex;
  align-items: center;

  .avatar {
    width: 42px;
    border-radius: 50%;
  }

  .info {
    font-size: 12px;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
    align-items: start;

    .t_shaodow {
      width: 50px;
      color: #333;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .t_nowrap {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>
